package com.cory.module.job.domain.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import com.cory.module.job.domain.vo.ExcelImportModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 
 *
 * @author xc
 * @since 2023-05-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@NoArgsConstructor
public class JobExcelImportDetail implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private Integer jobId;

    private Integer row;

    /**
     * 1成功，2失败
     */
    private Integer state;

    private Integer dataId;

    private String data;

    private String errorMsg;

    private String param1;

    private String param2;

    private String param3;

    public JobExcelImportDetail error(Integer jobId, ExcelImportModel vo) {
        this.jobId = jobId;
        this.state = 2;
        this.row = vo.getRowNum() + 1;
        this.errorMsg = vo.getErrorMsg();
        data = JSONObject.toJSONString(vo);
        return this;
    }
}
